package dto

import (
	"encoding/json"
	"github.com/crack007/go-im/src/common/constant"
	"github.com/crack007/go-im/src/common/util"
)

type MessageDto struct {
	Id          uint32               `json:"id"`
	From        uint32               `json:"from"`
	To          uint32               `json:"to"`
	MessageType constant.MessageType `json:"messageType"`
	CreatedAt   string               `json:"createdAt"`
	Data        string               `json:"data"`
	Action      string               `json:"action,omitempty"`
}

func NewMessageDto() *MessageDto {
	return &MessageDto{
		CreatedAt: util.GetDatetime(),
		Id:        0,
	}
}

func (d *MessageDto) String() string {
	marshal, _ := json.Marshal(d)
	return string(marshal)
}
